import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [

	{
		path: '/404',
		component: () => import('@/views/404'),
		hidden: true
	},
	{
		path: '/login',
		component: () => import('@/views/login/index'),
	},
	// {
	// 	path: '/',
	// 	component: () => import('@/views/pages2/index'),
	// },

	{
		path: '/',
		component: Layout,
		redirect: '/adminchat',
		// name: 'publishArticle',
		meta: {
			title: '素材管理模块',
			icon: 'el-icon-user-solid'
		},
		children: [{

				path: 'test',
				name: 'test',
				component: () => import('@/views/pages2/test'),
				meta: {
					title: '测试',
					icon: 'el-icon-user-solid'
				}
			}, {

				path: 'spgl',
				name: 'spgl',
				component: () => import('@/views/pages2/shipin'),
				meta: {
					title: '素材管理',
					icon: 'el-icon-user-solid'
				}

			},
			{
				path: 'wenan',
				name: 'wenan',
				component: () => import('@/views/pages2/wenan'),
				meta: {
					title: '文案管理',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'ypgl',
				name: 'ypgl',
				component: () => import('@/views/pages2/yinpin'),
				meta: {
					title: '音频管理',
					icon: 'el-icon-user-solid'
				}
			}, {
				path: 'adminchat',
				name: 'adminchat',
				component: () => import('@/views/pages2/index'),
				meta: {
					title: '获取链接',
					icon: 'el-icon-user-solid'
				}
			},
			{

				path: 'lianjiexiazai',
				name: 'lianjiexiazai',
				component: () => import('@/views/pages2/lianjiexiazai'),
				meta: {
					title: '链接下载',
					icon: 'el-icon-user-solid'
				}
			}
		]
	},
	{
		path: '/AI',
		component: Layout,
		redirect: '/AI',
		// name: 'publishArticle',
		meta: {
			title: 'AI合成模块',
			icon: 'el-icon-user-solid'
		},
		children: [{
				path: 'wjc',
				name: 'wjc',
				component: () => import('@/views/AI/wjc'),
				meta: {
					title: '违禁词管理',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'wenben',
				name: 'wenben',
				component: () => import('@/views/AI/wenben'),
				meta: {
					title: '产品卡片',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'liebiao',
				name: 'liebiao',
				component: () => import('@/views/AI/liebiao'),
				meta: {
					title: '本文列表',
					icon: 'el-icon-user-solid'
				},
				hidden: true
			},
			{
				path: 'shenyin',
				name: 'shenyin',
				component: () => import('@/views/AI/shenyin'),
				meta: {
					title: '声音列表',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'hecheng',
				name: 'hecheng',
				component: () => import('@/views/AI/hecheng'),
				meta: {
					title: '视频合成',
					icon: 'el-icon-user-solid'
				}
			}
		]
	},
	{
		path: '/video',
		component: Layout,
		redirect: '/video',
		// name: 'publishArticle',
		meta: {
			title: '视频模块',
			icon: 'el-icon-user-solid'
		},
		children: [{
				path: 'muban',
				name: 'muban',
				component: () => import('@/views/video/muban'),
				meta: {
					title: '模板视频',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'shipin',
				name: 'shipin',
				component: () => import('@/views/video/shipin'),
				meta: {
					title: '视频列表',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'wenti',
				name: 'wenti',
				component: () => import('@/views/video/wenti'),
				meta: {
					title: '问题视频',
					icon: 'el-icon-user-solid'
				}
			},
			{
				path: 'erchuang',
				name: 'erchuang',
				component: () => import('@/views/video/erchuang'),
				meta: {
					title: '视频二创',
					icon: 'el-icon-user-solid'
				}
			},
		]
	},
	// 404 page must be placed at the end !!!
	{
		path: '*',
		redirect: '/404',
		hidden: true
	}
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router